﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;


namespace LANmine
{
    public partial class SeatsForm : Form
    {
        private Language lmLang;

        public SeatsForm(Language Lang)
        {
            /** Save the language object */
            this.lmLang = Lang;

            /** Dock the window */
            this.Dock = DockStyle.Fill;

            InitializeComponent();
            ApplyLanguage();
            loadCoordinaten();
        }        


        #region Language Specifications
        /**
         * MainForm::ApplyLanguage()
         * ---------------------------
         * Overwrite all text properties of all elements in all forms with the right ones.
         */
        private void ApplyLanguage()
        {
            /**
             * Header label
             */
            this.lblSeats.Text = this.lmLang.GetString("menu.btnSeats");
        }
        #endregion


        private void loadCoordinaten()
        {
            Database dbCoordinaten = new Database("ro");
            SqlConnection dbConn = dbCoordinaten.getDbConn();
            dbConn.Open();

            SqlDataAdapter daCoordinaten = new SqlDataAdapter("Select * From plaatsen", dbConn);
            dbConn.Close();
            DataSet dsCoordinaten = new DataSet("Coordinaat");

            daCoordinaten.FillSchema(dsCoordinaten, SchemaType.Source, "Coordinaat");
            daCoordinaten.Fill(dsCoordinaten, "Coordinaat");

            DataTable dtCoordinaten;
            dtCoordinaten = dsCoordinaten.Tables["Coordinaat"];

            String x, y;
            //int xx = 35;
            //int yy = 65;

            foreach (DataRow drCurrent in dtCoordinaten.Rows)
            {
                x = drCurrent["x"].ToString();
                y = drCurrent["y"].ToString();
                //MessageBox.Show(x+" "+y);
                //xx += 10;
                //yy += 100;
                
                UserControl1 pictureBox3 = new UserControl1();
                pictureBox3.Location = new Point(Convert.ToInt32(x), Convert.ToInt32(y));
                
                //pictureBox3.Location = new Point(xx,yy);
                this.Controls.Add(pictureBox3);
                this.Controls.Add(pbParent);

                    
            }
        }
        


        private void SeatsForm_Load(object sender, EventArgs e)
        {
            loadCoordinaten();
            //pictureBox3.Image = Properties.Resources.seatsquare;
            // pictureBox1.Visible = true;
           
        }

       
    }
}
